package com.linkoog.devtools.view_remark;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;


public class ViewRemarkGroup extends DefaultActionGroup implements DumbAware{

    public ViewRemarkGroup() {
        super();
    }

    @Override
    public void update(@NotNull AnActionEvent event) {
       /* int size = ActionGroupUtil.getVisibleActions(this, e).take(getChildrenCountThreshold() + 1).size();
        e.getPresentation().setEnabledAndVisible(size > 0);
        e.getPresentation().setPopupGroup(size > getChildrenCountThreshold());*/

        Project project = event.getProject();
        VirtualFile virtualFile = event.getData(LangDataKeys.VIRTUAL_FILE);
        final Presentation presentation = event.getPresentation();
        if (project != null && virtualFile != null) {
            presentation.setEnabledAndVisible(virtualFile.isInLocalFileSystem());
            presentation.setPopupGroup(virtualFile.isInLocalFileSystem());
        } else {
            presentation.setEnabledAndVisible(false);
            presentation.setPopupGroup(false);
        }
        super.update(event);
    }


}
